//
//  Oos4ios.h
//  Oos4ios
//
//  Created by Pablo Gonzalez on 2/21/11.
//  Copyright 2011 11870.com. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import "DAOs/OosServiceDao.h"
#import "DAOs/OosReviewDao.h"
#import "DAOs/OosMultimediaDao.h"
#import "DAOs/OosContactDao.h"
#import "DAOs/OosCheckinDao.h"
#import "DAOs/OosActivityDao.h"
#import "DAOs/OosUserDao.h"
#import "DAOs/OosListDao.h"
#import "DAOs/OosTagDao.h"
#import "Model/OosUser.h"
#import "Model/OosMe.h"
#import "Model/OosService.h"
#import "Model/OosReview.h"
#import "Auth/IOosAuthenticationHandler.h"

@protocol LoadMeCallback <NSObject>

- (void) loadedWith: (OosMe *) me;
- (void) failedWith: (NSError *) error;

@end

/**
 Main EntryPoint for the 11870 API. 
 This is used as an access point to the rest of classes.
 */
@interface Oos4ios : NSObject {
	id <IOosAuthenticationHandler> mAuthenticationHandler;
	NSPersistentStoreCoordinator *mStoreCoordinator;
	OosMe *mMe;
}

/**
 Singleton access to the main EntryPoint for the 11870 API
 */
+ (Oos4ios *) instance;

/**
 Provides with a clean instance of OosServiceDao. This DAO is used to search
 sites.
 */
- (OosServiceDao *) serviceDao;

/**
 Provides with a clean instance of OosServiceDao related to the given user.
 This DAO is used to retrieve the services from the user.
 */
- (OosServiceDao *) serviceDaoFromUser: (OosUser *) user;

/**
 Provides with a clean instance of OosReviewDao from teh provided service. 
 This dao is used to retrieve the OosReview relative to the service.
 */
- (OosReviewDao *) reviewDao: (OosService *) service;

/**
 
 */
- (OosMultimediaDao *) multimediaDaoFromService: (OosService *) service;

- (OosContactDao *) contactDaoFromUser: (OosUser *) user;

- (OosCheckinDao *) checkinDaoFromUser: (OosUser *) user;

- (OosCheckinDao *) checkinDaoFromService: (OosService *) service;

- (OosActivityDao *) activityDaoFromUser: (OosUser *) user;

- (OosListDao *) listDaoFromUser: (OosUser *) user;

/**
 Provides with a clean instance of OosTagDao from the provided user.
 This is used to get all the tags that a user may have used to be used in auto 
 */
- (OosTagDao *) tagDaoFromUser: (OosUser *) user;

/**
 Returns an instance of the current logged  user or nul if  there isn't any.
 This user can be used to retrieve their information (Addressbook or contacts)
 */
@property (nonatomic, retain, readonly) OosMe *me;

- (void) loadMe: (id<LoadMeCallback>) callback;

/**
 The IOosAuthenticatonHandler is used to sing petitions to the api.
 By default and instance of AnonimousAuthenticationHandler is provided.
 */
@property (nonatomic, retain) id<IOosAuthenticationHandler> authenticationHandler; 

@property (nonatomic, retain, readonly) NSManagedObjectContext *managedContext;

- (BOOL) clearContext;

/**
 Used to determine if the user is logged in. This is useful to change the 
 behaviour of the user interface whether they are logged in or not.
 */
- (BOOL) authenticated;

@end
